home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / perl5000.zip / perl5000 / ext / util / make_ext < prev    next >
Encoding:
Text File  |  1994-10-07  |  1.8 KB  |  75 lines

  1. # This script acts as a simple interface for building extensions.
  2. # It primarily used by the perl Makefile:
  3. #
  4. # d_dummy $(dynamic_ext): miniperl preplibrary FORCE
  5. #        ext/util/make_ext dynamic $@
  6. #
  7. # It may be deleted in a later release of perl so try to
  8. # avoid using it for other purposes.
  9.  
  10. linktype=$1
  11. extspec=$2
  12.  
  13. case $CONFIG in
  14. '')
  15.     if test -f config.sh; then TOP=.;
  16.     elif test -f ../config.sh; then TOP=..;
  17.     elif test -f ../../config.sh; then TOP=../..;
  18.     elif test -f ../../../config.sh; then TOP=../../..;
  19.     elif test -f ../../../../config.sh; then TOP=../../../..;
  20.     else
  21.         echo "Can't find config.sh generated by Configure"; exit 1
  22.     fi
  23.     . $TOP/config.sh
  24.     ;;
  25. esac
  26.  
  27. if test "X$extspec" = X; then
  28.     echo "make_ext: no extension specified"
  29.     exit 1;
  30. fi
  31.  
  32. # convert old style Name.a into ext/Name/Name.a format
  33. case "$extspec" in
  34. ext/*) ;;
  35. *) extspec=`echo "$extspec" | sed -e 's:\(.*\)\.\(.*\):ext/\1/\1.\2:'`
  36. esac
  37.  
  38. # get extension directory path, module name and depth
  39. pname=`echo "$extspec" | sed -e 's:^ext/::' -e 's:/[^/]*$::'`
  40. mname=`echo "$pname"   | sed -e 's!/!::!'`
  41. depth=`echo "$pname"   | sed -e 's![^/][^/]*!..!g'`
  42.  
  43. if test ! -d "ext/$pname"; then
  44.     echo "    Skipping $extspec (directory does not exist)"
  45.     exit 0 # not an error ?
  46. fi
  47.  
  48. # check link type and do any preliminaries
  49. case "$linktype" in
  50. static)  makeargs='CCCDLFLAGS=' ;;
  51. dynamic) makeargs='' ;;
  52. *)    echo "make_ext: unknown link type '$linktype'"; exit 1;;
  53. '')    echo "make_ext: no link type specified (eg static or dynamic)"; exit 1;;
  54. esac
  55.  
  56. echo ""
  57. echo "    Making $mname ($linktype)"
  58.  
  59. cd ext/$pname
  60.  
  61. if test ! -f Makefile ; then
  62.     test -f Makefile.PL && ../$depth/miniperl -I../$depth/lib Makefile.PL
  63. fi
  64. if test ! -f Makefile ; then
  65.     test -f Makefile.SH && sh Makefile.SH
  66. fi
  67.  
  68. make=${altmake-make}
  69.  
  70. $make config
  71.  
  72. $make $linktype $makeargs
  73.  
  74. exit $?
  75.